//
//  TurnOverItemizedTableViewController.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/23.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "TurnOverItemizedTableViewController.h"
#import "TurnOverItemizedTableViewCell.h"

@interface TurnOverItemizedTableViewController ()

@property (nonatomic,strong)NSArray *turnOverItemizedArray;

@end


static NSString *const reuseIdentifier = @"Identifier";
@implementation TurnOverItemizedTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView = [[UIView alloc] init];
    
    self.tableView.backgroundColor = BACKGROUND_COLOR;
    
    self.title = @"营业额结算明细";
    
    [self loadTurnOverItemizedData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.turnOverItemizedArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TurnOverItemizedTableViewCell *itemized = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    
    if (!itemized) {
        itemized = [[TurnOverItemizedTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
        itemized.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    itemized.itemizedDict = self.turnOverItemizedArray[indexPath.row];
    
    return itemized;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 64;
}

- (NSArray *)turnOverItemizedArray {
    if (!_turnOverItemizedArray) {
        _turnOverItemizedArray = [NSArray array];
    }
    return _turnOverItemizedArray;
}

- (void)loadTurnOverItemizedData {
    [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:@{@"username":USERNAME} AndMenthodName:@"AppHz/pxjl" completeBlock:^(id object) {
        
        self.turnOverItemizedArray = [object objectForKey:@"data"][@"list"];
        
        NSLog(@"%@",self.turnOverItemizedArray);
        
        [self.tableView reloadData];
    }];
}
@end
